#include "UIFriendModel.h"
#include <QDateTime>
#include <QDebug>
using namespace IM_GUI_KIT;


UIFriendModel::UIFriendModel(QObject *parent):QObject (parent)
{
  qDebug()<<"init UIFriendModel";
}
UIFriendModel::~UIFriendModel()
{
  qDebug()<<"delete UIFriendModel :" <<m_sessionId ;
}

QString UIFriendModel::getSession() const
{
  return m_sessionId;
}

void UIFriendModel::setSession(const QString &sessionid)
{
  if(sessionid!=m_sessionId)
    m_sessionId=sessionid;
  emit sessionChanged();
}

UIFriendModel::UIFriendModel(const QString sessionid  , const QString &name, const QString &icon, const int64_t timestamp, const QString summary, int unRead, QObject *parent):QObject (parent)
{
  m_sessionId=sessionid;
  m_name=name;
  m_icon=icon;
  m_timestamp=timestamp;
  m_timeNow=QDateTime::fromTime_t(timestamp/1000).toString("hh:mm:ss");
  m_summary=summary;
  m_unread=unRead;
}

QString UIFriendModel::getName() const
{
  return m_name;
}

void UIFriendModel::setName(const QString &name)
{
  if(name!=m_name)
    m_name=name;
  emit nameChanged();
}

QString UIFriendModel::getIcon() const
{
  return m_icon;
}

void UIFriendModel::setIcon(const QString &icon)
{

  if (m_icon!=icon)
    m_icon=icon;
  emit iconChanged();
}

QString UIFriendModel::getTimeNow() const
{
  return m_timeNow;

}

void UIFriendModel::setTimeNow(const QString &timeNow)
{

  if (m_timeNow!=timeNow)
    m_timeNow=timeNow;
  emit timeNowChanged();
}

QString UIFriendModel::getSummary() const
{
  return m_summary;
}

void UIFriendModel::setSummary(const QString &summary)
{
  if (m_summary!=summary)
    m_summary=summary;
  emit summaryChanged();
}

int UIFriendModel::getUnread()
{
  return m_unread;
}

void UIFriendModel::setUnread(const int &unread)
{
  if (m_unread!=unread)
    m_unread=unread;
  emit unreadChanged();
}


